package com.wang.action;

import com.wang.entity.TbBbsArticle;
import com.wang.response.ResultResponse;
import com.wang.service.TbBbsArticleService;
import io.swagger.annotations.*;
import io.swagger.v3.oas.annotations.Operation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.io.IOException;

@RestController
@RequestMapping("/bbs")
@Api(tags="文章发布接口")
public class BbsArticleAction {
 @Resource
    private TbBbsArticleService bbsArticleService;

  //查询社区全部的文章

    @Operation(summary = "查询社区全部的文章")
    @PostMapping("findbbsarticle")
    private ResultResponse findbbsarticle(@RequestBody TbBbsArticle tbBbsArticle){
     return this.bbsArticleService.findBbsArticle(tbBbsArticle);
 }
    /*
   查询自己的
    */
    @Operation(summary = "查询自己的")
    @PostMapping("findBbsArticleuid/{userId}")
  private  ResultResponse findBbsArticleuid(@PathVariable Integer userId ){
       return this.bbsArticleService.findBbsArticleuid(userId);
  }

    /*
    发布文章
     */
    @PostMapping("insertBbsArticle")
    @Operation(summary = "发布文章")
   private ResultResponse insertBbsArticle(@RequestBody TbBbsArticle tbBbsArticle) throws Exception {
      return this.bbsArticleService.insertBbsArticle(tbBbsArticle);
   }
    /*
     删除文章  假删只是改变删除状态
     */
    @PostMapping("removeBbsArticle/{fileId}")
   private ResultResponse removeBbsArticle(@PathVariable Integer fileId){
   return this.bbsArticleService.removeBbsArticle(fileId);
   }
   @Operation(summary = "审核文章")
   @PostMapping("findaudit/{pagesize}/{pagenum}")
    private ResultResponse findaudit(@PathVariable Integer pagenum,@PathVariable Integer pagesize){
     return this.bbsArticleService.findaudit(pagenum,pagesize);
   }
   @Operation(summary = "修改审核状态")
    @PostMapping("updateaudit")
    private ResultResponse updateaudit(@RequestBody TbBbsArticle tbBbsArticle){
        return this.bbsArticleService.updateaudit(tbBbsArticle);
   }
   @Operation(summary = "es查询")
    @PostMapping("findes")
    private ResultResponse findes (@RequestBody TbBbsArticle tbBbsArticle)  throws IOException {
        return this.bbsArticleService.findes(tbBbsArticle);
   }
   @PostMapping("findall")
   @Operation(summary = "查询所有")
    private ResultResponse findall(){
        return this.bbsArticleService.findall();
   }

}
